<template>
  <div class="app-container">
    <!-- 表头表单 -->
    
    <el-table v-loading="loading" :data="postList" style="width: 100%" stripe border>
      <el-table-column prop="id" label="编号" width="90"></el-table-column>
      <el-table-column prop="postCode" label="岗位编码" width="180"></el-table-column>
      <el-table-column prop="name" label="岗位名称" width="180"></el-table-column>
      <el-table-column prop="status" label="描述"> 
        <template slot-scope="scope">
            <el-tag v-if="scope.row.status === 1" type="success">正常</el-tag>
            <el-tag v-if="scope.row.status === 0" type="danger">停用</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="description" label="备注"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
            <el-button size="mini" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handDelete(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import * as api from "@/api/system/post/post";
export default {
  data() {
    return {
      pageNo: 1,
      pageSize: 5,
      searchObj: {},
      postList: [],
      loading:true
    };
  },
  methods: {
    fetchData() {
      api
        .selectPage(this.pageNo, this.pageSize, this.searchObj)
        .then((response) => {
          this.postList = response.data.records;
          this.loading = false;
        })
        .catch((response) => {
          this.$message.error("服务异常,请刷新重试");
        });
    },
  },
  created() {
    this.fetchData();
  },
};
</script>
<style scoped>
</style>